<cfcomponent
	displayname="KalendarEvent"
	output="false"
	hint="A bean which models the KalendarEvent form.">

	<cfset variables.instance = StructNew() />

	<cffunction name="init" access="public" returntype="KalendarEvent" output="false">
		<cfargument name="AppAction" type="string" default="" />
		<cfargument name="CategoryName" type="string" default="" />
		<cfargument name="CategoryBGColor" type="string" default="" />
		<cfargument name="CategoryID" type="string" default="" />
		<cfargument name="CategoryTextColor" type="string" default="" />
		<cfargument name="ContactEmail" type="string" default="" />
		<cfargument name="ContactName" type="string" default="" />
		<cfargument name="ContactPhone" type="string" default="" />
		<cfargument name="DateTimeCreated" type="string" default="" />
		<cfargument name="Description" type="string" default="" />
		<cfargument name="EndDate" type="string" default="" />
		<cfargument name="EndTime" type="string" default="" />
		<cfargument name="EventID" type="string" default="" />
		<cfargument name="ExternalURL" type="string" default="" />
		<cfargument name="IsDeleted" type="string" default="" />
		<cfargument name="IsFeatured" type="string" default="" />
		<cfargument name="IsPublished" type="string" default="" />
		<cfargument name="LinkDate" type="string" default="" />
		<cfargument name="Location" type="string" default="" />
		<cfargument name="NewCategoryName" type="string" default="" />
		<cfargument name="StartDate" type="string" default="" />
		<cfargument name="StartTime" type="string" default="" />
		<cfargument name="Teaser" type="string" default="" />
		<cfargument name="Title" type="string" default="" />
		<cfargument name="View" type="string" default="" />
		

		<!--- run setters --->
		<cfset setAppAction(arguments.AppAction) />
		<cfset setCategoryName(arguments.CategoryName) />
		<cfset setCategoryBGColor(arguments.CategoryBGColor) />
		<cfset setCategoryID(arguments.CategoryID) />
		<cfset setCategoryTextColor(arguments.CategoryTextColor) />
		<cfset setContactEmail(arguments.ContactEmail) />
		<cfset setContactName(arguments.ContactName) />
		<cfset setContactPhone(arguments.ContactPhone) />
		<cfset setDateTimeCreated(arguments.DateTimeCreated) />
		<cfset setDescription(arguments.Description) />
		<cfset setEndDate(arguments.EndDate) />
		<cfset setEndTime(arguments.EndTime) />
		<cfset setEventID(arguments.EventID) />
		<cfset setExternalURL(arguments.ExternalURL) />
		<cfset setIsDeleted(arguments.IsDeleted) />
		<cfset setIsFeatured(arguments.IsFeatured) />
		<cfset setIsPublished(arguments.IsPublished) />
		<cfset setLinkDate(arguments.LinkDate) />
		<cfset setLocation(arguments.Location) />
		<cfset setNewCategoryName(arguments.NewCategoryName) />
		<cfset setStartDate(arguments.StartDate) />
		<cfset setStartTime(arguments.StartTime) />
		<cfset setTeaser(arguments.Teaser) />
		<cfset setTitle(arguments.Title) />
		<cfset setView(arguments.View) />
		
		<cfreturn this />
 	</cffunction>

	<!---
	ACCESSORS
	--->

	<!---  Usage: GetAppAction / SetAppAction  methods for AppAction value --->
	<cffunction name="getAppAction" access="public" output="false" returntype="string">
		<cfreturn variables.instance.AppAction />
	</cffunction>
	
	<cffunction name="setAppAction" access="public" output="false" returntype="void">
		<cfargument name="AppAction" type="string" required="true" />
		<cfset variables.instance.AppAction = arguments.AppAction />
	</cffunction>	
	
	<cffunction name="getCategoryBGColor" access="public" output="false" returntype="string">
		<cfreturn variables.instance.CategoryBGColor />
	</cffunction>
	
	<cffunction name="setCategoryBGColor" access="public" output="false" returntype="void">
		<cfargument name="CategoryBGColor" type="string" required="true" />
		<cfset variables.instance.CategoryBGColor = arguments.CategoryBGColor />
	</cffunction>
	
	<cffunction name="setCategoryID" access="public" returntype="void" output="false">
		<cfargument name="CategoryID" type="string" required="true" />
		<cfset variables.instance.CategoryID = arguments.CategoryID />
	</cffunction>
	<cffunction name="getCategoryID" access="public" returntype="string" output="false">
		<cfreturn variables.instance.CategoryID />
	</cffunction>

	<cffunction name="getCategoryName" access="public" output="false" returntype="string">
		<cfif hasNewCategory()>
			<cfreturn getNewCategoryName() />
		<cfelse>
			<cfreturn variables.instance.CategoryName />
		</cfif>
	</cffunction>
	
	<cffunction name="setCategoryName" access="public" output="false" returntype="void">
		<cfargument name="CategoryName" type="string" required="true" />
		<cfset variables.instance.CategoryName = arguments.CategoryName />
	</cffunction>
	
	<cffunction name="getCategoryTextColor" access="public" output="false" returntype="string">
		<cfreturn variables.instance.CategoryTextColor />
	</cffunction>
	
	<cffunction name="setCategoryTextColor" access="public" output="false" returntype="void">
		<cfargument name="CategoryTextColor" type="string" required="true" />
		<cfset variables.instance.CategoryTextColor = arguments.CategoryTextColor />
	</cffunction>

	<cffunction name="setContactEmail" access="public" returntype="void" output="false">
		<cfargument name="ContactEmail" type="string" required="true" />
		<cfset variables.instance.ContactEmail = arguments.ContactEmail />
	</cffunction>
	<cffunction name="getContactEmail" access="public" returntype="string" output="false">
		<cfreturn variables.instance.ContactEmail />
	</cffunction>

	<cffunction name="setContactName" access="public" returntype="void" output="false">
		<cfargument name="ContactName" type="string" required="true" />
		<cfset variables.instance.ContactName = arguments.ContactName />
	</cffunction>
	<cffunction name="getContactName" access="public" returntype="string" output="false">
		<cfreturn variables.instance.ContactName />
	</cffunction>

	<cffunction name="setContactPhone" access="public" returntype="void" output="false">
		<cfargument name="ContactPhone" type="string" required="true" />
		<cfset variables.instance.ContactPhone = arguments.ContactPhone />
	</cffunction>
	<cffunction name="getContactPhone" access="public" returntype="string" output="false">
		<cfreturn variables.instance.ContactPhone />
	</cffunction>
	
	<cffunction name="getDateTimeCreated" access="public" output="false" returntype="string">
		<cfreturn variables.instance.DateTimeCreated />
	</cffunction>
	
	<cffunction name="setDateTimeCreated" access="public" output="false" returntype="void">
		<cfargument name="DateTimeCreated" type="string" required="true" />
		<cfset variables.instance.DateTimeCreated = arguments.DateTimeCreated />
	</cffunction>
	
	<cffunction name="setDescription" access="public" returntype="void" output="false">
		<cfargument name="Description" type="string" required="true" />
		<cfset variables.instance.Description = arguments.Description />
	</cffunction>

	<cffunction name="getDescription" access="public" returntype="string" output="false">
		<cfreturn variables.instance.Description />
	</cffunction>
	<cffunction name="setEndDate" access="public" returntype="void" output="false">
		<cfargument name="EndDate" type="string" required="true" />
		<cfset variables.instance.EndDate = arguments.EndDate />
	</cffunction>
	
	<cffunction name="getEndDate" access="public" returntype="string" output="false">
		<cfset var rtnValue = "" />
		<cfif isDate( variables.instance.EndDate) >
			<cfset rtnValue = variables.instance.EndDate />
		<cfelseif isDate( getStartDate() ) >
			<cfset rtnValue = getStartDate() />
		</cfif>
		
		<cfreturn rtnValue />
	</cffunction>
	
	<cffunction name="setEndTime" access="public" returntype="void" output="false">
		<cfargument name="EndTime" type="string" required="true" />
		<cfset variables.instance.EndTime = arguments.EndTime />
	</cffunction>
	<cffunction name="getEndTime" access="public" returntype="string" output="false">
		<cfset var rtnValue = "" />
		<cfif isDate( variables.instance.EndTime ) >
			<cfset rtnValue = timeformat( variables.instance.EndTime, getKalendarConfig().getLongTimeMask() ) />
		</cfif>
		<cfreturn rtnValue />
	</cffunction>
	<cffunction name="setEventID" access="public" returntype="void" output="false">
		<cfargument name="EventID" type="string" required="true" />
		<cfset variables.instance.EventID = arguments.EventID />
	</cffunction>
	<cffunction name="getEventID" access="public" returntype="string" output="false">
		<cfreturn variables.instance.EventID />
	</cffunction>

	<cffunction name="setExternalURL" access="public" returntype="void" output="false">
		<cfargument name="ExternalURL" type="string" required="true" />
		<cfset variables.instance.ExternalURL = arguments.ExternalURL />
	</cffunction>
	<cffunction name="getExternalURL" access="public" returntype="string" output="false">
		<cfreturn variables.instance.ExternalURL />
	</cffunction>
	
	<cffunction name="getIsDeleted" access="public" output="false" returntype="string">
		<cfreturn variables.instance.IsDeleted />
	</cffunction>
	
	<cffunction name="setIsDeleted" access="public" output="false" returntype="void">
		<cfargument name="IsDeleted" type="string" required="true" />
		<cfset variables.instance.IsDeleted = arguments.IsDeleted />
	</cffunction>
		
	<cffunction name="setIsFeatured" access="public" returntype="void" output="false">
		<cfargument name="IsFeatured" type="string" required="true" />
		<cfset variables.instance.IsFeatured = arguments.IsFeatured />
	</cffunction>
	<cffunction name="getIsFeatured" access="public" returntype="string" output="false">
		<cfreturn variables.instance.IsFeatured />
	</cffunction>

	<cffunction name="setIsPublished" access="public" returntype="void" output="false">
		<cfargument name="IsPublished" type="string" required="true" />
		<cfset variables.instance.IsPublished = arguments.IsPublished />
	</cffunction>
	<cffunction name="getIsPublished" access="public" returntype="string" output="false">
		<cfreturn variables.instance.IsPublished />
	</cffunction>

	<cffunction name="getLinkDate" access="public" output="false" returntype="string">
		<cfset var rtnDate = now() />
		<cfif isDate( variables.instance.LinkDate ) >
			<cfset rtnDate = variables.instance.LinkDate />
		</cfif>
		<cfreturn rtnDate />
	</cffunction>
	
	<cffunction name="setLinkDate" access="public" output="false" returntype="void">
		<cfargument name="LinkDate" type="string" required="true" />
		<cfset variables.instance.LinkDate = arguments.LinkDate />
	</cffunction>

	<cffunction name="setLocation" access="public" returntype="void" output="false">
		<cfargument name="Location" type="string" required="true" />
		<cfset variables.instance.Location = arguments.Location />
	</cffunction>
	<cffunction name="getLocation" access="public" returntype="string" output="false">
		<cfreturn variables.instance.Location />
	</cffunction>	

	<cffunction name="getNewCategoryName" access="public" output="false" returntype="string">
		<cfreturn variables.instance.NewCategoryName />
	</cffunction>
	
	<cffunction name="setNewCategoryName" access="public" output="false" returntype="void">
		<cfargument name="NewCategoryName" type="string" required="true" />
		<cfset variables.instance.NewCategoryName = arguments.NewCategoryName />
	</cffunction>
	
	<cffunction name="hasNewCategory" access="public" output="false" returntype="boolean">
		<cfreturn len( trim( getNewCategoryName() ) ) />
	</cffunction> 
	
	<cffunction name="setStartDate" access="public" returntype="void" output="false">
		<cfargument name="StartDate" type="string" required="true" />
		<cfset variables.instance.StartDate = arguments.StartDate />
	</cffunction>
	<cffunction name="getStartDate" access="public" returntype="string" output="false">
		<cfset var rtnValue = "" />
		<cfif isDate( variables.instance.StartDate) >
			<cfset rtnValue = variables.instance.StartDate />
		</cfif>
		
		<cfreturn rtnValue />
	</cffunction>

	<cffunction name="getShortEndDate" access="public" returntype="string" output="false">
		<cfset var rtnValue = "" />
		<cfif isDate( getEndDate() ) >
			<cfset rtnValue = dateFormat( getEndDate(), getKalendarConfig().getShortDateMask() ) />
		</cfif>
		
		<cfreturn rtnValue />
	</cffunction>

	<cffunction name="getShortStartDate" access="public" returntype="string" output="false">
		<cfset var rtnValue = "" />
		<cfif isDate( getStartDate() ) >
			<cfset rtnValue = dateFormat( getStartDate(), getKalendarConfig().getShortDateMask() ) />
		</cfif>
		
		<cfreturn rtnValue />
	</cffunction>

	<cffunction name="setStartTime" access="public" returntype="void" output="false">
		<cfargument name="StartTime" type="string" required="true" />
		<cfset variables.instance.StartTime = arguments.StartTime />
	</cffunction>
	<cffunction name="getStartTime" access="public" returntype="string" output="false">
		<cfset var rtnValue = "" />
		<cfif isDate( variables.instance.StartTime ) >
			<cfset rtnValue = timeformat( variables.instance.StartTime, getKalendarConfig().getLongTimeMask() ) />
		</cfif>
<!--- 		<cfdump var="#variables.instance.StartTime#"><cfdump var="#rtnValue#"><cfdump var="#createodbctime(rtnValue)#"><cfabort showError="This is the start time bit" /> --->
		<cfreturn rtnValue />
	</cffunction>

	<cffunction name="setTeaser" access="public" returntype="void" output="false">
		<cfargument name="Teaser" type="string" required="true" />
		<cfset variables.instance.Teaser = arguments.Teaser />
	</cffunction>
	<cffunction name="getTeaser" access="public" returntype="string" output="false">
		<cfreturn variables.instance.Teaser />
	</cffunction>

	<cffunction name="setTitle" access="public" returntype="void" output="false">
		<cfargument name="Title" type="string" required="true" />
		<cfset variables.instance.Title = arguments.Title />
	</cffunction>
	<cffunction name="getTitle" access="public" returntype="string" output="false">
		<cfreturn variables.instance.Title />
	</cffunction>

	<cffunction name="getView" access="public" output="false" returntype="string">
		<cfreturn variables.instance.View />
	</cffunction>
	
	<cffunction name="setView" access="public" output="false" returntype="void">
		<cfargument name="View" type="string" required="true" />
		<cfset variables.instance.View = arguments.View />
	</cffunction>

	<cffunction name="getMemento" access="public" returntype="struct" output="false">
		<cfreturn variables.instance />
	</cffunction>


	<!--- Private getter function --->

	<cffunction name="getKalendarConfig" access="private" output="false" returntype="any">
		<cfreturn variables.instance.KalendarConfig />
	</cffunction>
	
	<cffunction name="setKalendarConfig" access="public" output="false" returntype="void">
		<cfargument name="KalendarConfig" type="any" required="true" />
		<cfset variables.instance.KalendarConfig = arguments.KalendarConfig />
	</cffunction>

</cfcomponent>